package com.tongzhan.controller;

import com.tongzhan.base.Return;
import com.tongzhan.service.ZongjiaoService;
import com.tongzhan.vo.SiteInfoVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 宗教
 */
@RequestMapping("/zongjiao")
@RestController
public class ZongjiaoController {

    @Autowired
    private ZongjiaoService zongjiaoService;

    /**
     * 获取宗教大屏地图列表
     * @param type
     * @param date
     * @param siteType 场所类型 0-宗教场所 1-民间信仰点
     * @param religionCode 场所类型 01-佛教、02-道教、03-基督教、 04-民间信仰点
     * @return
     */
    @RequestMapping("/getMapList")
    public Return getMapList(Integer type, String date,Integer siteType,String religionCode,String addressName) {
        Map<String, Object> map = new HashMap<>();
        List<SiteInfoVO> list = zongjiaoService.getMapList(type,date, siteType,religionCode,addressName);
        map.put("list",list);
        return Return.getSuccessResult(map);
    }

    /**
     * 获取宗教场所统计
     * @return
     */
    @RequestMapping("/getReligionList")
    public Return getReligionList(Integer type,String date) {
        Map<String, Object> map = zongjiaoService.getReligionList(type, date);
        return Return.getSuccessResult(map);
    }

    /**
     * 获取宗教人员统计
     * @param type
     * @param date
     * @return
     */
    @RequestMapping("/getUserInfoList")
    public Return getUserInfoList(Integer type,String date) {
        Map<String, Object> map = zongjiaoService.getUserInfoList(type, date);
        return Return.getSuccessResult(map);
    }

    /**
     * 获取收入支出
     * @param type
     * @param date
     * @return
     */
    @RequestMapping("/getBillList")
    public Return getBillList(Integer type,String date) {
        Map<String, Object> map = zongjiaoService.getBillList(type, date);
        return Return.getSuccessResult(map);
    }

    /**
     * 获取财务规范上报次数，活动安全上报次数
     * @param type
     * @param date
     * @return
     */
    @RequestMapping("/getBillActivityCount")
    public Return getBillActivityCount(Integer type,String date) {
        Map<String, Object> map = zongjiaoService.getBillActivityCount(type, date);
        return Return.getSuccessResult(map);
    }

    /**
     * 获取综合分析
     * @param type
     * @param date
     * @return
     */
    @RequestMapping("/getInspectionList")
    public Return getInspectionList(Integer type,String date) {
        Map<String, Object> map = zongjiaoService.getInspectionList(type, date);
        return Return.getSuccessResult(map);
    }

    /**
     * 获取安全统计
     * @param type
     * @param date
     * @return
     */
    @RequestMapping("/getSafeList")
    public Return getSafeList(Integer type,String date) {
        Map<String, Object> map = zongjiaoService.getSafeList(type, date);
        return Return.getSuccessResult(map);
    }

    /**
     * 获取检查列表
     * @return
     */
    @GetMapping("/getTypeList")
    public Return getTypeList() {
        return Return.getSuccessResult(zongjiaoService.getTypeList());
    }

    /**
     * 获取教派类型列表
     * @return
     */
    @GetMapping("/getReligionTypeList")
    public Return getReligionTypeList() {
        return Return.getSuccessResult(zongjiaoService.getReligionTypeList());
    }

    /**
     * 根据教派编码获取场所列表
     * @param religionCode
     * @param type 标记 值为1需加入团体
     * @return
     */
    @PostMapping("/getSiteListByReligionCode")
    public Return getSiteListByReligionCode(String religionCode, Integer type) {
        if (StringUtils.isEmpty(religionCode)) {
            return Return.getMissParamResult();
        }
        return Return.getSuccessResult(zongjiaoService.getSiteListByReligionCode(religionCode, type));
    }

    /**
     * 常规统计
     * @return
     */
    @GetMapping("/conventionalCount")
    public Return conventionalCount() {
        return Return.getSuccessResult(zongjiaoService.conventionalCount());
    }

    /**
     * 请销假统计
     * @return
     */
    @GetMapping("/leaveCount")
    public Return leaveCount() {
        return Return.getSuccessResult(zongjiaoService.leaveCount());
    }

    /**
     * 安全检查统计详情
     * @param religionCode 教派编码
     * @param siteCode 场所编码
     * @param typeCode 类型编码
     * @param status 0-无问题 1-需整改 2-已整改
     * @return
     */
    @PostMapping("/getInspectionDetail")
    public Return getInspectionDetail(String religionCode, String siteCode, String typeCode, Integer status) {
        return Return.getSuccessResult(zongjiaoService.getInspectionDetail(religionCode, siteCode, typeCode, status));
    }

    /**
     * 人员统计详情
     * @param religionCode 教派编码
     * @param siteCode 场所编码
     * @param type 0-暂住 1-常住
     * @return
     */
    @PostMapping("/getPersonnelDetail")
    public Return getPersonnelDetail(String religionCode, String siteCode, Integer type) {
        return Return.getSuccessResult(zongjiaoService.getPersonnelDetail(religionCode, siteCode, type));
    }

    /**
     * 常规统计详情
     * @param type 1-政策法规 2-通知中心 3-平安报送 4-情况报告 5-活动记录
     * @return
     */
    @PostMapping("/getConventionalDetail")
    public Return getConventionalDetail(Integer type) {
        if (type == null) {
            return Return.getMissParamResult();
        }
        return Return.getSuccessResult(zongjiaoService.getConventionalDetail(type));
    }

    /**
     * 场所统计详情
     * @param religionCode
     * @return
     */
    @PostMapping("/getSiteDetail")
    public Return getSiteDetail(String religionCode) {
        return Return.getSuccessResult(zongjiaoService.getSiteDetail(religionCode));
    }

    /**
     * 场所统计详情
     * @param religionCode
     * @param siteCode
     * @param year
     * @param month
     * @return
     */
    @PostMapping("/getBillDetail")
    public Return getBillDetail(String religionCode, String siteCode, String year, String month) {
        return Return.getSuccessResult(zongjiaoService.getBillDetail(religionCode, siteCode, year, month));
    }

    /**
     * 人员请销假统计详情
     * @param religionCode
     * @param time
     * @param state 0-已销假 1-未销假
     * @return
     */
    @PostMapping("/getLeaveDetail")
    public Return getLeaveDetail(String religionCode, String time, Integer state) {
        return Return.getSuccessResult(zongjiaoService.getLeaveDetail(religionCode, time, state));
    }
}
